package jmetal.util.comparators;

import hidra.jmetal.core.Solution;
import java.util.Comparator;

public class DensityEstimatorComparator implements Comparator {

	@Override
	public int compare(Object ob1, Object ob2) {
		if (ob1 == null) {
			return 1;
		} else if (ob2 == null) {
			return -1;
		}

		double dEstimator1 = ((Solution) ob1).getDensityEstimator();
		double dEstimator2 = ((Solution) ob2).getDensityEstimator();

		if (dEstimator1 > dEstimator2) {
			return -1;
		} else if (dEstimator1 < dEstimator2) {
			return 1;
		} else { 
			return 0;
		}
	}

}
